package com.qd.common.panda.domain.entity.space;

import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.qd.common.panda.domain.entity.info.ParkInfoDTO;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Optional;

/**
 * 车位租赁信息
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class ParkSpaceDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "租赁ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "租赁ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String sid;
    /**
     * 租赁开始时间
     */
    @NotBlank(message = "租赁开始时间不能为空", groups = DefaultGroup.class)
    @Size(max = 10, message = "租赁开始时间长度不能超过{max}位", groups = DefaultGroup.class)
    private String startDate;
    /**
     * 租赁结束时间
     */
    @NotBlank(message = "租赁结束时间不能为空", groups = DefaultGroup.class)
    @Size(max = 10, message = "租赁结束时间长度不能超过{max}位", groups = DefaultGroup.class)
    private String endDate;
    /**
     * 租赁开始小时
     */
    private String startHour;
    /**
     * 租赁结束小时
     */
    private String endHour;
    /**
     * 租赁天数
     */
    private Long days;
    /**
     * 发布时间
     */
    private LocalDateTime publishTime;
    /**
     * 更新时间
     */
    private LocalDateTime updateTime;
    /**
     * 状态:1运行中2停运中3已租赁
     */
    private Integer state;
    /**
     * 状态显示
     */
    private String stateDisplay;
    /**
     * 预期日收益
     */
    private BigDecimal expectedDayRevenue;
    /**
     * 预期日收益显示
     */
    private String expectedDayRevenueDisplay;
    /**
     * 预期总收益
     */
    private BigDecimal expectedTotalRevenue;
    /**
     * 预期总收益显示
     */
    private String expectedTotalRevenueDisplay;
    /**
     * 总收益
     */
    private BigDecimal totalRevenue;
    /**
     * 总收益显示
     */
    private String totalRevenueDisplay;
    /**
     * 扣费后总收益
     */
    private BigDecimal deductionTotalRevenue;
    /**
     * 扣费后总收益显示
     */
    private String deductionTotalRevenueDisplay;
    /**
     * 分成比例
     */
    private Double shareRatio;
    /**
     * 退款金额
     */
    private BigDecimal refundAmount;
    /**
     * 退款金额显示
     */
    private String refundAmountDisplay;
    /**
     * 扣费金额
     */
    private BigDecimal deductionAmount;
    /**
     * 扣费金额显示
     */
    private String deductionAmountDisplay;
    /**
     * 车位ID
     */
    @Size(max = 50, message = "车位长度不能超过{max}位", groups = DefaultGroup.class)
    private String aid;
    /**
     * 是否发布
     */
    @Size(max = 50, message = "是否发布长度不能超过{max}位", groups = DefaultGroup.class)
    private String isPublish;
    /**
     * 是否发布显示
     */
    private String isPublishDisplay;
    /**
     * 发布人
     */
    @Size(max = 50, message = "发布人长度不能超过{max}位", groups = DefaultGroup.class)
    private String publisher;
    /**
     * 停车场ID
     */
    private String parkId;
    /**
     * 停车场ID显示
     */
    private String parkIdDisplay;
    /**
     * 是否可租
     */
    @Size(max = 50, message = "是否可租长度不能超过{max}位", groups = DefaultGroup.class)
    private String rentable;
    /**
     * 是否可租显示
     */
    private String rentableDisplay;
    /**
     * 是否分账
     */
    private String divideAccounts;
    /**
     * 是否分账显示
     */
    private String divideAccountsDisplay;
    /**
     * 是否结束
     */
    private String end;
    /**
     * 是否结束显示
     */
    private String endDisplay;
    /**
     * 车位发布ID
     */
    @Size(max = 50, message = "车位发布ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String publishId;
    /**
     * 租赁类型
     */
    @NotBlank(message = "租赁类型不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "租赁类型长度不能超过{max}位", groups = DefaultGroup.class)
    private String leaseType;
    /**
     * 租赁类型显
     */
    private String leaseTypeDisplay;
    /**
     * 车位信息
     */
    private ParkInfoDTO parkInfo;

    @Override
    public void freeData() {
        this.sid = null;
        this.startDate = null;
        this.endDate = null;
        this.startHour = null;
        this.endHour = null;
        this.days = null;
        this.publishTime = null;
        this.updateTime = null;
        this.state = null;
        this.stateDisplay = null;
        this.expectedDayRevenue = null;
        this.expectedDayRevenueDisplay = null;
        this.expectedTotalRevenue = null;
        this.expectedTotalRevenueDisplay = null;
        this.totalRevenue = null;
        this.totalRevenueDisplay = null;
        this.deductionTotalRevenue = null;
        this.deductionTotalRevenueDisplay = null;
        this.shareRatio = null;
        this.refundAmount = null;
        this.refundAmountDisplay = null;
        this.deductionAmount = null;
        this.deductionAmountDisplay = null;
        this.aid = null;
        this.isPublish = null;
        this.isPublishDisplay = null;
        this.publisher = null;
        this.parkId = null;
        this.parkIdDisplay = null;
        this.rentable = null;
        this.rentableDisplay = null;
        this.divideAccounts = null;
        this.divideAccountsDisplay = null;
        this.leaseType = null;
        this.leaseTypeDisplay = null;
        Optional.ofNullable(parkInfo).ifPresent(ParkInfoDTO::freeData);
        super.freeData();
    }
}
